#include <iostream>
#include <sstream>

#include "Clock.h"
#include "Pulse.h"
#include "CurrentCreation.h"
#include "FieldCreation.h"
#include "MultiLayer.h"
#include "Output.h"
#include "TrajSimul.h"
#include "PhDSimul.h"
#include "InitialPosition.h"
#include "ICritvsLengthDiffHAlgo.h"
#include "CurrentvsLengthSimul.h"
#include "PhDMeanSimul.h"
#include "LoopSimul.h"
#include "AstroidSimul.h"
#include "EnergySimul.h"
#include "PulseDelaySimul.h"
#include "SecondPulseSimul.h"
#include "NewParameters.h"
#include <Qt/QtXml>
#include <QString>
#include <QDataStream>
#include <QTextStream>
#include <QApplication>
#include <QtGui>
#include "MainWindow.h"

int main(int argc, char *argv[])
{
  
  QTextStream cout(stdout,QIODevice::WriteOnly);
  QTextStream cin(stdin,QIODevice::ReadOnly);
  //NewParameters params=NewParameters();
  //params.getParameters("../test_parameters.xml");
  QApplication app(argc,argv);
  app.setStyle(new QPlastiqueStyle);
  MainWindow *mainWindow = new MainWindow();
  mainWindow->show();
  return app.exec();
  /*
  int choice;

  //Creation of the objects we will need during the simulation
  Clock clock=Clock(params);
  cout<<"timestamp="<<clock.getTimeStamp()<<endl;
  cout<<"timestep="<<clock.getTimeStep()<<endl;
  cout<<"timewindow="<<clock.getTimeWindow()<<endl;
  
  CurrentCreation *currentfactory=new CurrentCreation();
  Pulse *current=currentfactory->NewPulse(params);
  current->Current(params);
  cout<<"I="<<current->getLevel(clock.getTimeStamp())<<endl;
 
  FieldCreation * fieldfactory=new FieldCreation();
  Pulse * field=fieldfactory->NewPulse(params);
  field->Field(params);
  cout<<"B="<<field->getLevel(clock.getTimeStamp())<<endl;
  
  MultiLayer multiLayer=MultiLayer(params);
  
  QString filename="test.txt";
  Output output;
  output=Output();
 
  int layerNumber=1; 

  cout<<"Choose a simulation"<<endl;
  cout<<"1-Trajectory"<<endl;
  cout<<"2-Phase Diagram(H-I)"<<endl;
  cout<<"3-Icrit vs Pulse Length"<<endl;
  cout<<"5-Phase Diagram with last nanosecond averaged"<<endl;
  cout<<"6-Loop R(H)"<<endl;
  cout<<"7-Current vs Pulse Length"<<endl;
  cout<<"8-Astroid"<<endl;
  cout<<"9-Phase Diagram with energy"<<endl;
  cout<<"10-Delay simul"<<endl;
  cout<<"11-second pulse"<<endl;
  cin>>choice;
  cout<<"choice="<<choice<<endl;
  //cout<<"Give a filename";
  //cin>>filename;
  output.initialize(filename);
  switch(choice)
    {
    case 1:
      {     
	cout<<"Do you want the initial position calculated? press y for yes"<<endl;
	QString position;
	cin>>position;
	if(position=="y")
	  {
	    multiLayer[layerNumber].setMag(InitialPosition(clock,output,field,current,multiLayer,params)); 
	  }
	TrajSimul().solve(clock,output,field,current,multiLayer,params);
	break;
      }
    case 5:
      PhDMeanSimul().solve(clock,output,field,current,multiLayer,params);
      break;
    case 2:
      PhDSimul().solve(clock,output,field,current,multiLayer,params);
      break;
    case 3:
      ICritvsLengthDiffHAlgo().solve(clock,output,field,current,multiLayer,params);
      break;
    case 7:
      CurrentvsLengthSimul().solve(clock,output,field,current,multiLayer,params);
      break;
    case 6:
      //LoopSimul simul();
      //simul= new LoopSimul();
      //simul.solve(clock,output,field,current,multiLayer);
      LoopSimul().solve(clock,output,field,current,multiLayer,params);
      break;
    case 8:
      AstroidSimul().solve(clock,output,field,current,multiLayer,params);
      break;
    case 9:
      EnergySimul().solve(clock,output,field,current,multiLayer,params);
      break;
    case 10:
      PulseDelaySimul().solve(clock,output,field,current,multiLayer,params);
      break;
    case 11:
      SecondPulseSimul().solve(clock,output,field,current,multiLayer,params);
      break;
    default:
      cout<<"you didn't choose any simulation"<<endl;
      }
  */
}


